import axios from 'axios';

// 上传头像
export const uploadAvatar = async (formData, uid) => {
    try {
        const response = await axios.post(`http://localhost:8080/UFiles/upLodeAvatar?uid=${uid}`, formData, {
            headers: { 'Content-Type': 'multipart/form-data' },
        });
        return response.data;
    } catch (error) {
        console.error('Error uploading avatar:', error.response ? error.response.data : error.message);
        throw error;
    }
};


// 获取用户文件信息
export const getUserAvatar = async (uid) => {
    try {
        const response = await axios.get(`http://localhost:8080/UFiles/${uid}`);
        return response.data;
    } catch (error) {
        console.error('Error getting avatar:', error.response ? error.response.data : error.message);
        throw error;
    }
};
